package gui.viewEntity;

import java.util.ArrayList;

import framework.classification.entities.ClAbstractEntity;
import framework.classification.entities.ClInterfaceProvided;
import framework.classification.library.AbstractClassfication;
import framework.entity.ACLEntity;
import framework.entity.ACLFunction;
import framework.entity.ACLInterface;
import gui.controller.Controller;

public class ViewACLInterface extends ViewACLEntity{

	public ViewACLInterface(ACLEntity aclEntity,
			AbstractClassfication classfication,Controller controller) {
		super(aclEntity, classfication,controller);
		// TODO Auto-generated constructor stub
	}

	@Override
	public ArrayList<ClAbstractEntity> FillClassifyElement() {
		ArrayList<ClAbstractEntity> list = new ArrayList<ClAbstractEntity>();
		if (classification.getInterfacesProvided().containsKey(aclEntity.getName()))
			list.add(classification.getInterfacesProvided().get(aclEntity.getName()));
		if (classification.getInterfacesRequired().containsKey(aclEntity.getName()))
			list.add(classification.getInterfacesRequired().get(aclEntity.getName()));
		//System.out.println(classification.getInterfacesProvided().toString());
		return list;
		
	}

	@Override
	public String getDescriptionLeft() {
		// TODO Auto-generated method stub
		return "Function";
	}

	@Override
	public String getDescriptionRight() {
		// TODO Auto-generated method stub
		return "Component including interface";
	}

	@Override
	public ArrayList<String> getLeftParty() {
		// TODO Auto-generated method stub
		ACLInterface interface1 = (ACLInterface) aclEntity;
		ArrayList<String> result = new ArrayList<String>();
		for (ACLFunction func : interface1.getFunctions()){
			result.add(func.toString());
		}
		return result;
	}

	@Override
	public ArrayList<String> getRightParty() {
		// TODO Auto-generated method stub
		ArrayList<String> result = new ArrayList<String>();
		String nameReq = "REQ-"+aclEntity.getName();
		String namePro = "PRO-"+aclEntity.getName();
		
		if (classification.getStructure().getInterfacesToComponent().containsKey(nameReq)){
			for (String compo : classification.getStructure().getInterfacesToComponent().get(nameReq)){
				if (!result.contains(compo))
					result.add(compo);
			}
		}
		if (classification.getStructure().getInterfacesToComponent().containsKey(namePro)){
			for (String compo : classification.getStructure().getInterfacesToComponent().get(namePro)){
				if (!result.contains(compo))
					result.add(compo);
			}
		}
		return result;
	}

}
